package biz

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	v1 "hello-kratos/kratos-client/api/v1"
)

type UserUseCase struct {
	repo UserRepo
	l    *log.Helper
}

func NewUserUseCase(repo UserRepo, logger log.Logger) *UserUseCase {
	return &UserUseCase{
		repo: repo,
		l:    log.NewHelper(logger),
	}
}

func (uc *UserUseCase) Login(ctx context.Context, req *v1.LoginRequest) error {
	return uc.repo.Login(ctx, &UserLogin{
		UserName: req.GetUsername(),
		PassWord: req.GetPassword(),
	})
}

func (uc *UserUseCase) GetUserInfo(ctx context.Context, id string) (*UserLogin, error) {
	return uc.repo.GetUserInfo(ctx, id)
}

type UserLogin struct {
	UserName string `json:"user_name"`
	PassWord string `json:"pass_word"`
}
type UserRepo interface {
	Login(ctx context.Context, ul *UserLogin) error
	GetUserInfo(ctx context.Context, id string) (*UserLogin, error)
}
